home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power Programmierung
/
Power-Programmierung (Tewi)(1994).iso
/
magazine
/
dbms_mag
/
9103
/
cea4.mar
< prev
next >
Wrap
Text File
|
1991-01-28
|
4KB
|
128 lines
/*****************************************************************
* LastLog.C
* written by Kathy Cea, Platinum Software Int'l
*
* InGroup is a utility to list the last login date and time of
* all network users.
*
* Calling Syntax:
* LastLog
*
* Compiled in Turbo C 2.0 with NetWare C function calls
*
* Note: This version of the program contains minimal formatting
* of the output. It is designed to demonstrate use of
* the NetWare APIs. The full version of LastLog.C is
* available on TelePath.
*****************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <nit.h>
#include <niterror.h>
#define MAXNAME 48
void getlastlog (char *);
int i,j;
main(){
WORD objectType;
char objectName[MAXNAME];
long objectId;
int retcode;
BYTE propertyValue[128];
BYTE moreSegs,
propertyFlags;
int segNum;
BYTE temp[3];
BYTE holdobjId[9];
char *endptr;
segNum = 1;
moreSegs = 255;
/* Get all users of group EVERYONE
Object ID of users are passed back in the propertyValue field
Up to 32 Object Ids can be returned on each pass. Continue
calling ReadPropertyValue until moreSegs is No (0) */
while (moreSegs) {
retcode = ReadPropertyValue("EVERYONE", OT_USER_GROUP,
"GROUP_MEMBERS", segNum,
propertyValue, &moreSegs, &propertyFlags);
segNum++;
/* parse the propertyValue for 4-byte Object IDs,
then convert each ID to a long integer */
i = 0;
temp[2] = '\0';
holdobjId[0] = '\0';
while (i < 128) {
for (j=0; j < 4; j++) {
/* Build a hex string for each Object ID */
sprintf(temp, "%02x", propertyValue[i]);
temp[2] = '\0';
strcat(holdobjId, temp);
i++;
} /* for (j=0; j < 4; j++) */
objectId = strtoul(holdobjId, &endptr, 16);
/* Pass user's Object ID and receive User Name */
retcode = GetBinderyObjectName(objectId, objectName, &objectType);
if (!retcode)
getlastlog(objectName);
holdobjId[0] = '\0';
} /* while (i < 128) */
} /* while (moreSegs) */
} /* main() */
void getlastlog (char objectName[MAXNAME])
/* Gets the last login date & time and the full name for the
user passed in objectName */
{
WORD objectType;
int retcode;
BYTE propertyValue[128];
BYTE moreSegs,
propertyFlag;
char lastlogdt[9];
char lastlogtm[9];
objectType = OT_USER;
/* Read the user's LOGIN_CONTROL property value to obtain the last
login date & time */
retcode = ReadPropertyValue(objectName, objectType, "LOGIN_CONTROL", 1,
propertyValue, &moreSegs, &propertyFlag);
if (!retcode){
sprintf(lastlogdt,"%02d/%02d/%02d",
propertyValue[57],
propertyValue[58],
propertyValue[56]);
sprintf(lastlogtm,"%02d:%02d:%02d",
propertyValue[59],
propertyValue[60],
propertyValue[61]);
lastlogdt[8] = '\0';
lastlogtm[8] = '\0';
/* Read the user's IDENTIFICATION property value to obtain the
full name */
retcode = ReadPropertyValue(objectName, objectType, "IDENTIFICATION", 1,
propertyValue, &moreSegs, &propertyFlag);
printf("%-20s",objectName);
printf("%-35s",propertyValue);
if (!strcmp(lastlogdt,"00/00/00"))
printf("No Logins\n");
else
printf("%-8s\t%-8s\n",lastlogdt, lastlogtm);
} /* if (!retcode) */
else {
printf("%-20s",objectName);
printf("%44s\n","No Logins");
}
return;
}